<%@ page language="java" pageEncoding="UTF-8"
	contentType="text/html;charset=UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("basePath", basePath);
%>
<!DOCTYPE>
<html>
<head>
<title>明细信息</title>
	<%@ include file="/resources/js/easyui/taglibs.jsp"%>
	<%@ include file="/resources/js/easyui/_easyui.jsp"%>
	<%@ include file="/resources/js/easyui/_message.jsp"%>
	<%@ include file="/resources/js/easyui/_viewJS.jsp"%>
</head>

<body class="easyui-layout">
	<form id="addform">
		<table class="tableForm" style="width: 100%;">

			<tr>
				<th align="right" valign="top"><span class="redStart">*</span><label>用户组名称（中文）：</label></th>
				<td><input class="easyui-validatebox easyui-textbox"
					name="namecn" style="width:200px"
					data-options="required:true,validType:'chinese'" /></td>
			</tr>

			<tr>
				<th align="right" valign="top"><span class="redStart">*</span><label>用户组名称（英文）：</label></th>
				<td><input class="easyui-validatebox easyui-textbox"
					name="sname" style="width:200px"
					data-options="required:true,validType:'english'" /></td>
			</tr>

			<tr>
				<th align="right" valign="top"><label>用户组说明：</label></th>
				<td><input class="easyui-textbox" name="remark"
					data-options="multiline:true" style="width:200px;height:60px;"></td>
			</tr>

			<tr>
				<th align="right" valign="top"><label>（需要改造）用户组类型：</label></th>
				<td>
					<div style="float: left;">
						<input type="radio" name="ntype" value="1">系统管理 <input
							type="radio" name="ntype" value="2" checked="checked">商业用户
						<input type="radio" name="ntype" value="3">商业子账户
					</div>

					<div id="GC_PatentUserGroup"
						style="float: left; margin-left: 4px;display: none;">
						<label>所属用户组：</label><select class="easyui-combobox" style="width:100px;" id="proleid" name="proleid"
							data-options="panelHeight:'auto'" >
						</select>
					</div>
				</td>
			</tr>

			<tr>
				<th align="right" valign="top"><label>默认自动分配：</label></th>
				<td><input type="radio" name="isdefault" value="1"
					checked="checked">是</input> <input type="radio" name="isdefault"
					value="0">否</td>
			</tr>

			<tr>
				<th align="right" valign="top"><label>是否可分配：</label></th>
				<td><input type="radio" name="isshare" value="1"
					checked="checked">是</input> <input type="radio" name="isshare"
					value="0">否</td>
			</tr>

			<tr>
				<th align="right" valign="top"><label>用户组状态：</label></th>
				<td><input type="radio" name="state" value="1"
					checked="checked">启用</input> <input type="radio" name="state"
					value="2">停用</td>
			</tr>

		</table>

	</form>

	<script type="application/javascript">
	$("input[type='radio'][name='ntype']").click(function(){
		if($(this).val() == '3'){
			$.ajax({
				url:'${basePath}web/userGroup/parentUserGroup.json',
				type : 'GET',
				dataType:'json',
				async : false,
				success: function (data) {
					console.log(data);
					$("#proleid").combobox({ valueField: "userGroupid",  textField: "textCN", data: data });
					$("#proleid").combobox('setText','请选择');
					$("#GC_PatentUserGroup").show();
					
				},error:function(response){
					ViewHelper.func.ajaxErrorMessage(response);
				}
			});
		}else{
			$("#proleid").val("");
			$("#GC_PatentUserGroup").hide();
		}
		
	});

	function add(){
		
		if($("#addform").form('validate')){
			alert("test");
			$.ajax({
				url:'${basePath}web/userGroup/newUserGroup',
				type : 'POST',
				data : $("#addform").serialize(),
				async : false,
				traditional:true,
				error: function (response) {
					ViewHelper.func.ajaxErrorMessage(response);
				},
				success: function (ret) {
					if(ret.result) {
						$.messager.alert('提示信息！',ret.info,'info');
						parent.view.closeAddWin(1);
						$("#addform").form('clear');
					}else{
						$.messager.alert('提示','保存失败!','error');
					}
				}
			});
		}
	}
	
	$.extend($.fn.validatebox.defaults.rules, {
		chinese: {
			 validator : function(value) {
                 return /^[\u0391-\uFFE5]+$/.test(value);
             },
             message : '请输入正确的中文名称'
		},
		english:{
			validator: function(value){
				return /^[a-zA-Z]+$/.test(value);
			},
			message: '请输入正确的英文名称'
		}
		
	});

	</script>
</body>
</html>
